﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OrmAuto;

public partial class Controls_RicercheAjaxControl : System.Web.UI.UserControl
{
    QuerierLight mQueri = null;
    public string UrlPaginaRisultati { get; set; }
    public bool ShowButtonSearch { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Inizializza();	
    }//fM

    protected override void OnPreRender(EventArgs e)
    {
        UrlPaginaRisultati =  this.Page.AppRelativeVirtualPath;
        if (!string.IsNullOrEmpty(UrlPaginaRisultati))
        {
            UrlPaginaRisultati = ResolveUrl(UrlPaginaRisultati);
            this.myImageButtonSearch.PostBackUrl = UrlPaginaRisultati;
        }
        this.myImageButtonSearch.Visible = ShowButtonSearch; 

            base.OnPreRender(e);

    }//fM

    private void Inizializza()
    {
        mQueri = new QuerierLight();

        this.myDropMarche.DataTextField = "Marca";
        this.myDropMarche.DataValueField = "ID";
        this.myDropMarche.DataSource = mQueri.getMarche();
        this.myDropMarche.DataBind();

        this.myDropPossessi.DataTextField = "Possesso";
        this.myDropPossessi.DataValueField = "ID";
        this.myDropPossessi.DataSource = mQueri.getPossessi();
        this.myDropPossessi.DataBind();

        this.myDropColori.DataTextField = "Colore";
        this.myDropColori.DataValueField = "ID";
        this.myDropColori.DataSource = mQueri.getColori();
        this.myDropColori.DataBind();

        this.myStatiDrop.DataTextField = "STATO_Stato";
        this.myStatiDrop.DataValueField = "STATO_ID";
        this.myStatiDrop.DataSource = mQueri.getStati();
        this.myStatiDrop.DataBind();
        var item = this.myStatiDrop.Items.FindByText("ITALIA (ITALY)");
        if (item != null) item.Selected = true;

        this.myTipiDrop.DataTextField = "TipoIT";
        this.myTipiDrop.DataValueField = "ID";
        this.myTipiDrop.DataSource = mQueri.getTipiAuto();
        this.myTipiDrop.DataBind();
        this.myTipiDrop.Items.FindByText("Auto/Car").Selected = true;



    }//fM



}//fC
